package com.qiantu.phone.other;

import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.widget.TextView;

import androidx.appcompat.widget.AppCompatTextView;

import com.hjq.bar.style.LightBarStyle;
import com.hjq.base.DensityUtils;
import com.hjq.widget.view.PressAlphaTextView;
import com.qiantu.phone.R;
import com.qiantu.phone.app.AppApplication;

/**
 *    author : Android 轮子哥
 *    github : https://github.com/getActivity/AndroidProject
 *    time   : 2021/02/27
 *    desc   : 标题栏初始器
 */
public final class TitleBarStyle extends LightBarStyle {

    @Override
    public TextView newTitleView(Context context) {
        return new AppCompatTextView(context);
    }

    @Override
    public TextView newLeftView(Context context) {
        return new PressAlphaTextView(context);
    }

    @Override
    public TextView newRightView(Context context) {
        return new PressAlphaTextView(context);
    }

    @Override
    public Drawable getTitleBarBackground(Context context) {
        return AppApplication.getInstance().getThemeDrawable(R.attr.titleBgAndShadowLine);
    }

    @Override
    public Drawable getTitleBarNoLineBackground(Context context) {
        return new ColorDrawable(AppApplication.getInstance().getThemeColor(R.attr.shapeSolidColor));
    }

    @Override
    public Drawable getBackButtonDrawable(Context context) {
        return AppApplication.getInstance().getThemeDrawable(R.attr.icon_navigationbar_back);
    }

    @Override
    public Drawable getLeftTitleBackground(Context context) {
        return null;
    }

    @Override
    public Drawable getRightTitleBackground(Context context) {
        return null;
    }

    @Override
    public int getChildHorizontalPadding(Context context) {
        return (int) context.getResources().getDimension(R.dimen.dp_16);
    }

    @Override
    public int getChildVerticalPadding(Context context) {
        return (int) context.getResources().getDimension(R.dimen.dp_16);
    }

    @Override
    public float getTitleSize(Context context) {
        return context.getResources().getDimension(R.dimen.dp_16);
    }



    @Override
    public float getLeftTitleSize(Context context) {
        return context.getResources().getDimension(R.dimen.dp_13);
    }

    @Override
    public float getRightTitleSize(Context context) {
        return context.getResources().getDimension(R.dimen.dp_14);
    }

    @Override
    public int getTitleIconPadding(Context context) {
        return (int) context.getResources().getDimension(R.dimen.dp_2);
    }

    @Override
    public int getLeftIconPadding(Context context) {
        return (int) context.getResources().getDimension(R.dimen.dp_10);
    }

/*    @Override
    public int getLeftIconPaddingStart(Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16, context.getResources().getDisplayMetrics());
    }

    @Override
    public int getLeftIconPaddingEnd(Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics());
    }

    @Override
    public int getLeftIconPaddingTop(Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics());
    }

    @Override
    public int getLeftIconPaddingBottom(Context context) {
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10, context.getResources().getDisplayMetrics());
    }*/

    @Override
    public int getRightIconPadding(Context context) {
        return (int) context.getResources().getDimension(R.dimen.dp_10);
    }

    @Override
    public int getTitleStyle(Context context) {
        return 1;
    }

    @Override
    public int getLeftIconWidth(Context context) {
        return DensityUtils.dip2px(context, 16);
    }



    @Override
    public int getLeftIconHeight(Context context) {
        return DensityUtils.dip2px(context, 16);
    }

    @Override
    public ColorStateList getTitleColor(Context context) {
        return ColorStateList.valueOf(AppApplication.getInstance().getThemeColor(R.attr.textColor1));
    }

    @Override
    public boolean isLineVisible(Context context) {
        return true;
    }

    @Override
    public int getRightIconWidth(Context context) {
        return DensityUtils.dip2px(context, 16);
    }

    @Override
    public int getRightIconHeight(Context context) {
        return DensityUtils.dip2px(context, 16);
    }

    /*@Override
    public ColorStateList getRightTitleColor(Context context) {
        return context.getResources().getColorStateList(R.color.title_right_color);
    }*/

    @Override
    public Drawable getLineDrawable(Context context) {
//        return new ColorDrawable(AppApplication.getInstance().getThemeColor(R.attr.themeColor));
        return AppApplication.getInstance().getResources().getDrawable(R.drawable.shadow_top_line);
    }

    @Override
    public int getLineSize(Context context) {
        return AppApplication.getInstance().getResources().getDimensionPixelSize(R.dimen.dp_4);
    }

    @Override
    public boolean isShadowLine(){
        return true;
    }
}